package exception;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.ObjectMapper;

import po.Response;
import util.ResponseUtil;

public class ExceptionHandler {
	private Exception e;
	private HttpServletRequest request;
	private HttpServletResponse response;
	private ObjectMapper mapper = new ObjectMapper();

	public ExceptionHandler(Exception e2, HttpServletRequest request,
			HttpServletResponse response) {
		this.e = e2;
		this.request = request;
		this.response = response;
	}

	public static void setTipMsg(Exception e, HttpServletRequest req) {

	}

	public static void setResponsePage(Exception e, HttpServletRequest request,
			HttpServletResponse response) {

	}

	public void handler() {
		if (e instanceof InputExecption) {
			try {
				Response res = new Response(false,((InputExecption) e).getMsg(),null);
				ResponseUtil.write(res, response);
			} catch (IOException e1) {
				e1.printStackTrace();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}
	}

}
